<?php
    $data = $this->requestAction(array('controller'=>'jobseekers','action'=>'get_resume',$jobseeker_id));  
    $age = (substr(date("Y-m-d"),0,4) - substr($data['Jobseeker']['date_of_birth'],0,4)) ." years";
    
    
    function mydate($date)
    {
       $day=substr($date,8,2);
       $mymonth = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
       $month=substr($date,5,2);
       $year=substr($date,0,4);
       $temp=$day.' '.$mymonth[$month-1].' '.$year;
       return $temp;
    }    
    
    echo "<div id='resume_area'>";
        
        
            if($data['Resume']['upload_photo']!='')
            { 
                echo "<div class='foto'>";
                echo $html->image('../'.$data['Resume']['upload_photo'],array('class'=>'photo')); 
                echo "</div>";
            }
            else
            { echo "&nbsp";}
        
        echo "<span class='nama'>";
        echo $data['Jobseeker']['salution']." ".$data['Jobseeker']['first_name']." ".$data['Jobseeker']['last_name'];
        echo "</span>";
    
        echo "<span class='last_update'>";
        echo "<b>Last Update : </b>".mydate($data['Resume']['modified'])."&nbsp ";
        echo "</span>";    
        
        echo "<span class='judul'>Personal Detail</span>";
        echo "<table cellspacing=0 cellpadding=0>";
            echo "<tr><td class='field'>Gender</td><td class='isi'>: ".$data['Jobseeker']['gender']."</td></tr>";
            echo "<tr><td class='field'>Age</td><td class='isi'>: ".$age."</td></tr>";
            echo "<tr><td class='field'>Date of Birth</td><td class='isi'>: ".mydate($data['Jobseeker']['date_of_birth'])."</td></tr>";
            if($data['Jobseeker']['martial_status']=='')
            { $data['Jobseeker']['martial_status']='-'; }
            echo "<tr><td class='field'>Martial Status</td><td class='isi'>: ".$data['Jobseeker']['martial_status']."</td></tr>";
            echo "<tr><td class='field'>Nasionalism</td><td class='isi'>: ".$data['Jobseeker']['nasionalism']."</td></tr>";
            echo "<tr><td class='field'>Ethnic</td><td class='isi'>: ".$data['Jobseeker']['ethnic']."</td></tr>";
            echo "<tr><td class='field'>Member</td><td class='isi'>: ".$data['Jobseeker']['member']."</td></tr>";
            echo "<tr><td class='field'>Religion</td><td class='isi'>: ".$data['Religion']['name']."</td></tr>";
        echo "</table>";
        
        echo "<span class='judul'>Contact Info</span>";    
        echo "<table cellspacing=0 cellpadding=0>";
            echo "<tr><td class='field'>Address</td><td class='isi'>: ".$data['Jobseeker']['address'].", ".$data['City']['name']." ".$data['Jobseeker']['postal_code']."</td></tr>";
            if($data['Jobseeker']['home_no']!='')
            { echo "<tr><td class='field'>Telephone No.</td><td class='isi'>: ".$data['Jobseeker']['home_no']."</td></tr>"; }
            else
            { echo "<tr><td class='field'>Telephone No.</td><td class='isi'>: -</td></tr>"; }
            if($data['Jobseeker']['mobile_no']!='')
            { echo "<tr><td class='field'>Mobile No.</td><td class='isi'>: ".$data['Jobseeker']['mobile_no']."</td></tr>"; }
            else
            { echo "<tr><td class='field'>Mobile No.</td><td class='isi'>: -</td></tr>"; }
            echo "<tr><td class='field'>Email</td><td class='isi'>: <a href='mailto:".$data['Jobseeker']['email']."' class='sky'>".$data['Jobseeker']['email']."</a></td></tr>";
        echo "</table cellspacing=0 cellpadding=0>";

        echo "<span class='judul'>Summary</span>";  
        echo "<table cellspacing=0 cellpadding=0>";
            if($data['Resume']['score']=='')
            { $data['Resume']['score']='-'; }
            echo "<tr><td class='field'>Highest Academic</td><td class='isi'>: ".$data['academic_name']." ( score : ".$data['Resume']['score']." )</td></tr>";

            if($data['Resume']['work_exp']==0)
            { $result = 'Still on Studying'; }
            if($data['Resume']['work_exp']==1)
            { $result = 'Fresh Graduate'; }
            if($data['Resume']['work_exp']==2)
            { $result = $data['Resume']['month_exp']." month(s) - ".$data['Resume']['year_exp']." year(s)"; }
            echo "<tr><td class='field'>Working Experience</td><td class='isi'>: ".$result."</td></tr>";

            if($data['Resume']['avaibility']==0)
            { $result = 'Available'; }
            if($data['Resume']['avaibility']==1)
            { $result = 'Available after '.mydate($data['Resume']['date_avaible']); }
            if($data['Resume']['avaibility']==2)
            { $result = 'Not Available'; }
            echo "<tr><td class='field'>Avaibility status</td><td class='isi'>: ".$result."</td></tr>";
            if( $data['Resume']['salary']!='' )
            { echo "<tr><td class='field'>Expexted Salary</td><td class='isi'>: Rp. ".$data['Resume']['salary']."</td></tr>"; }
            else
            { echo "<tr><td class='field'>Expexted Salary</td><td class='isi'>: Negotiable</td></tr>"; }
        echo "</table>";
        
        echo "<span class='judul'>Additional Information</span>"; 
        echo "<table cellspacing=0 cellpadding=0>";
            if($data['Resume']['vehicle']!='')
            { echo "<tr><td class='field'>Owned Vehicle</td><td class='isi'>: ".$data['Resume']['vehicle']."</td></tr>"; }
            if($data['Resume']['travel']!='')
            { echo "<tr><td class='field'>Willing to Travel</td><td class='isi'>: ".$data['Resume']['travel']."</td></tr>"; }
            if($data['Resume']['relocate']!='')
            { echo "<tr><td class='field'>Willing to Relocate</td><td class='isi'>: ".$data['Resume']['relocate']."</td></tr>"; }
            if($data['Resume']['overseas']!='')
            { echo "<tr><td class='field'>Willing to Overseas</td><td class='isi'>: ".$data['Resume']['overseas']."</td></tr>"; }
        echo "</table>";
        echo "<br><span class='field'>Self Description : </span>";
        if( $data['Resume']['self_desc']=="" )
        { $data['Resume']['self_desc']=" - "; }
        echo "<br><div style='margin-left:50px;margin-right:300px;' >".$data['Resume']['self_desc']."</div>";        
        
        
        echo "<span class='judul'>Education History</span>";
        echo "<table class='mine' cellspacing=0 cellpadding=0>"; 
            if(count($data['Education']))
            {
                echo "<tr> <th align='center' width='100px'>Period</th> <th width='150px'>School Name</th> <th width='200px'>Location</th> <th width='120px'>Qualification</th> <th width='120px'>Major</th> <th width='50px'>Grade</th> </tr>";
                foreach($data['Education'] as $temp)
                {
                    echo "<tr>";
                        echo "<td align='center'>".$temp['start_period']." - ".$temp['end_period']."</td>";
                        echo "<td>".$temp['school']."</td>";
                        if($temp['location']!='')
                        { echo "<td>".$temp['location']."</td>"; }
                        else
                        { echo "<td> - </td>"; }
                        echo "<td>".$temp['qualification']."</td>";
                        if($temp['major']!='')
                        { echo "<td>".$temp['major']."</td>"; }
                        else
                        { echo "<td>-</td>"; }
                        if($temp['grade']!='')
                        { echo "<td>".$temp['grade']."</td>"; }
                        else
                        { echo "<td>-</td>"; }                        
                    echo "</tr>";
                }
            }
            else
            { echo "<tr><td colspan='6'><span class='red'>* There is no record in Education History</span></td></tr>"; }
        echo "</table>";
        echo "<br><span class='field'>Certification : </span>";
        
        if( $data['Resume']['certificate']=="" )
        { $data['Resume']['certificate']=" - "; }
        echo "<br><div style='margin-left:50px;margin-right:300px;' >".$data['Resume']['certificate']."</div>";
         
        echo "<span class='judul'>Working History</span>"; 
        echo "<table class='mine' cellspacing=0 cellpadding=0>"; 
            if(count($data['Work']))
            {
                echo "<tr> <th width='150px' align='center'>Period</th> <th width='150px'>Company</th> <th width='120px'>Position</th> <th width='120px'>Salary</th> <th>Job Duties / Achievements</th> </tr>";
                foreach($data['Work'] as $temp)
                {
                    echo "<tr>";
                        echo "<td align='center'>".$temp['start_month']." ".$temp['start_year']." - ".$temp['end_month']." ".$temp['end_year']."</td>";
                        echo "<td>".$temp['company']."</td>";
                        echo "<td>".$temp['position']."</td>";
                        if($temp['salary']=='')
                        { $temp['salary']=0; }
                        echo "<td> Rp.".$temp['salary']."</td>";
                        if($temp['duties']=='')
                        { $temp['duties']='-'; }
                        echo "<td>".$temp['duties']."</td>";
                    echo "</tr>";
                }
            }
            else
            { echo "<tr><td colspan='5'><span class='red'>* There is no record in Working Experience History</span></td></tr>"; }
        echo "</table>";
        
        echo "<span class='judul'>Top Skills</span>"; 
        echo "<table class='mine' cellspacing=0 cellpadding=0>"; 
            if(count($data['Skill']))
            {
                echo "<tr> <th width='200px'>Skill</th> <th width='120px'>Proficiency</th> <th width='200px' align='center'>Year Experience</th> </tr>";
                foreach($data['Skill'] as $temp)
                {
                    echo "<tr>";
                        echo "<td>".$temp['name']."</td>";
                        echo "<td>".$temp['proficiency']."</td>";
                        echo "<td align='center'>".$temp['year']."</td>";
                    echo "</tr>";
                }
            }
            else
            { echo "<tr><td colspan='3'><span class='red'>* There is no record in Top Skills</span></td></tr>"; }
        echo "</table>";        
        
        echo "<span class='judul'>Languages</span>"; 
        echo "<table class='mine' cellspacing=0 cellpadding=0>"; 
            if(count($data['Language']))
            {
                echo "<tr> <th width='200px'>Language</th> <th width='120px'>Reading</th width='120px'> <th width='120px'>Writting</th> <th width='120px'>Listening</th> <th width='120px'>Speaking</th> </tr>";
                foreach($data['Language'] as $temp)
                {
                    echo "<tr>";
                        echo "<td>".$temp['name']."</td>";
                        echo "<td>".$temp['read']."</td>";
                        echo "<td>".$temp['write']."</td>";
                        echo "<td>".$temp['listen']."</td>";
                        echo "<td>".$temp['speak']."</td>";
                    echo "</tr>";
                }
            }
            else
            { echo "<tr><td colspan='5'><span class='red'>* There is no record in Languages Skill</span></td></tr>"; }
        echo "</table>";

        echo "<br><br>";
        echo "<center><b>- End of Resume -</b></center>";

    
    echo "</div>";
 ?>
